﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class StockInfo2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Binddate();
           

        }
    }
    /*protected void btnUpdate_Click(object sender, EventArgs e)
    {
        users us = new users();
        us.id = txtUpdate.Text.Trim();
        us.name = txtUpdate.Text.Trim();
        GVmerch1.DataSource = us.GetOneUsers2(us);
        GVmerch1.DataBind();
        GVmerch1.Visible = true;
    }*/
    protected void GVmerch1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string id = GVmerch1.DataKeys[e.RowIndex].Value.ToString().Trim();
        string id1 = ((TextBox)(GVmerch1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.Trim();
        string name = ((TextBox)(GVmerch1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.Trim();
        string desc = ((TextBox)(GVmerch1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.Trim();
        string provideid = ((TextBox)(GVmerch1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.Trim();
        string price = ((TextBox)(GVmerch1.Rows[e.RowIndex].Cells[6].Controls[0])).Text.Trim();
        string num = ((TextBox)(GVmerch1.Rows[e.RowIndex].Cells[7].Controls[0])).Text.Trim();
        string total = ((TextBox)(GVmerch1.Rows[e.RowIndex].Cells[8].Controls[0])).Text.Trim();
        string buydate = ((TextBox)(GVmerch1.Rows[e.RowIndex].Cells[9].Controls[0])).Text.Trim();
        users tmp = new users();
        tmp.id = id;
        tmp.id1 = id1;
        tmp.name = name;
        tmp.price = price;
        tmp.descn = desc;
        tmp.num = num;
        tmp.total = total ;
        tmp.buydate = buydate ;
        tmp.proid = provideid ;
        tmp.Updateoneuser1(tmp);
    }
    protected void Binddate()
    {
        users us = new users();
        GVmerch1.DataSource = us.GetAllUsers(us);
        GVmerch1.DataBind();
    }
    protected void GVmerch1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GVmerch1.EditIndex = e.NewEditIndex;
        Binddate();
    }
    protected void chkAll_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox chkAll = (CheckBox)sender;
        foreach (GridViewRow gvRow in GVmerch1.Rows) ;
        {
            CheckBox chkItem = (CheckBox)GVmerch1.FindControl("chkItem");
            chkItem.Checked = chkAll.Checked;
        }

    }
    protected void GVmerch1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    
   /* protected void GVmerch1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType ==DataControlRowType .DataRow )
        {
            try
            {
                //获取删除连接按钮
                LinkButton lnkbtnDelete = (LinkButton)e.Row.Cells[4].Controls[0];
                lnkbtnDelete.OnClientClick = "return confirm('您真要删除分类名为" + e.Row.Cells[1].Text + "的记录吗？‘）；";
            }
            catch
            {

            }
        }
    }*/
    protected void GVmerch1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string id = GVmerch1.DataKeys[e.RowIndex].Value.ToString().Trim();
        users us = new users();
        us.id = id;
        us.delete1(us);
        Binddate();
    }
    protected void GVmerch1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            try
            {
                LinkButton lnkbtnDelete = (LinkButton)e.Row.Cells[10].Controls[0];
                lnkbtnDelete.OnClientClick = "return confirm('您真的要删除订单" + e.Row.Cells[1].Text + "的记录吗？');";
            }
            catch
            {

            }
        }
    }
}